<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html">
<head>
<title>View Alert</title>
</head>
<body>
<ui:composition template="/template.xhtml">
	<ui:define name="navigation">
		<ui:include src="navigation.xhtml" />
	</ui:define>
	
	<ui:define name="heading">
		<h:outputText value="Alert Search" />
	</ui:define>

	<ui:define name="body">
		<h:form id="form">
			<h:panelGrid id="searchGrid" columns="4">
				<h:outputText value="Stock Exchange" />
				<h:outputText value="Trx Type" />
				<h:outputText value="Active/Inactive" />
				<h:outputText value="" />

				<h:selectOneListbox value="#{alertSearchBean.stockExchange}" required="true">
					<f:selectItem itemLabel="BSE" itemValue="BSE" />
					<f:selectItem itemLabel="NYSE" itemValue="NYSE" />
				</h:selectOneListbox>
				<h:selectOneListbox value="#{alertSearchBean.trxType}" required="true">
					<f:selectItem itemLabel="Buy" itemValue="Buy" />
					<f:selectItem itemLabel="Sell" itemValue="Sell" />
					<f:selectItem itemLabel="Virtual Buy" itemValue="Virtual Buy" />
					<f:selectItem itemLabel="Virtual Sell" itemValue="Virtual Sell" />
				</h:selectOneListbox>
				<h:selectOneListbox value="#{alertSearchBean.isActive}" required="false">
					<f:selectItem itemLabel="All" itemValue="" />
					<f:selectItem itemLabel="Active" itemValue="Y" />
					<f:selectItem itemLabel="Inactive" itemValue="N" />
				</h:selectOneListbox>
				<h:commandButton value="Go" actionListener="#{alertSearchBean.search}" />
			</h:panelGrid>
			<hr />
			
			<h:outputText value="#{alertSearchBean.graphHtmlContent}" escape="false" />
			
			<h:panelGroup rendered="#{alertSearchBean.stockExchange == 'BSE'}">
				<h:dataTable value="#{alertSearchBean.dmBseAlertResults}" var="alertResult" border="1">
					<h:column>
						<f:facet name="header">
							<h:outputText value="Stock Code" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.bseIciciMapping.stockCode}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Trx Type" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.trxType}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Event Date" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.eventDate}" />
					</h:column>
					<!-- h:column>
						<f:facet name="header">
							<h:outputText value="Opportunity Type" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.opportunityType}" />
					</h:column -->
					<h:column>
						<f:facet name="header">
							<h:outputText value="Event Price" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.eventPrice}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Target Price" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.targetPrice}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="SLTP" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.sltp}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Qty" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.qty}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Event Type" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.eventType}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Active" />
						</f:facet>
						<h:outputText value="#{alertResult.alert.isActive}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="CMP" />
						</f:facet>
						<h:panelGroup>
							<h:graphicImage value="images/up.jpg" rendered="#{alertResult.bse.close &gt; alertResult.alert.eventPrice}" />
							<h:graphicImage value="images/down.jpg" rendered="#{alertResult.bse.close &lt; alertResult.alert.eventPrice}" />

							<h:outputText value="#{alertResult.bse.close}" />
						</h:panelGroup>
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="% Chg" />
						</f:facet>
						<h:outputText value="#{alertResult.percentChange}%" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Edit" />
						</f:facet>
						<h:commandLink value="Edit" actionListener="#{alertSearchBean.editAlert}" action="alert" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Graph" />
						</f:facet>
						<h:commandLink value="Graph" actionListener="#{alertSearchBean.viewGraph}" />
					</h:column>
				</h:dataTable>
			</h:panelGroup>

			<h:panelGroup rendered="#{alertSearchBean.stockExchange == 'NYSE'}">
				<h:dataTable value="#{alertSearchBean.dmNyseAlertResults}" var="alertResult" border="1">
					<h:column>
						<f:facet name="header">
							<h:outputText value="Symbol" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.symbol}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Trx Type" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.trxType}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Event Date" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.eventDate}" />
					</h:column>
					<!-- h:column>
						<f:facet name="header">
							<h:outputText value="Opportunity Type" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.opportunityType}" />
					</h:column -->
					<h:column>
						<f:facet name="header">
							<h:outputText value="Event Price" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.eventPrice}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Target Price" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.targetPrice}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="SLTP" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.sltp}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Qty" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.qty}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Event Type" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.eventType}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Active" />
						</f:facet>
						<h:outputText value="#{alertResult.nyseAlert.isActive}" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="CMP" />
						</f:facet>
						<h:panelGroup>
							<h:graphicImage value="images/up.jpg" rendered="#{alertResult.nyse.close &gt; alertResult.nyseAlert.eventPrice}" />
							<h:graphicImage value="images/down.jpg" rendered="#{alertResult.nyse.close &lt; alertResult.nyseAlert.eventPrice}" />

							<h:outputText value="#{alertResult.nyse.close}" />
						</h:panelGroup>
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="% Chg" />
						</f:facet>
						<h:outputText value="#{alertResult.percentChange}%" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Edit" />
						</f:facet>
						<h:commandLink value="Edit" actionListener="#{alertSearchBean.editNyseAlert}" action="alert" />
					</h:column>
					<h:column>
						<f:facet name="header">
							<h:outputText value="Graph" />
						</f:facet>
						<h:commandLink value="Graph" actionListener="#{alertSearchBean.viewNyseGraph}" />
					</h:column>
				</h:dataTable>
			</h:panelGroup>

		</h:form>
	</ui:define>
</ui:composition>
</body>
</html>
